/**
 * input change callback react hook 
 */


export const useInput = (callback) => {
  const [value, setValue] = useState('');
  const [error, setError] = useState('');

  const onChange = (e) => {
    setValue(e.target.value);
    callback(e.target.value);
  };

  const onBlur = (e) => {
    setError('');
    callback(e.target.value);
  };

  return {
    value,
    error,
    onChange,
    onBlur,
  };
};